module(
    name = "toolchain-examples",
    version = "0.0.0",
    compatibility_level = 0,
)

bazel_dep(name = "platforms", version = "1.0.0")

# C++
bazel_dep(name = "rules_cc", version = "0.1.5")

# Java
bazel_dep(name = "rules_java", version = "8.11.0")

java = use_extension("//java:extensions.bzl", "toolchains")
use_repo(java, "local_jdk")

# Python
bazel_dep(name = "rules_python", version = "1.2.0")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
    hub_name = "pip",
    python_version = "3.12",
    requirements_lock = "//:requirements_lock.txt",
)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    is_default = True,
    python_version = "3.12",
)

use_repo(pip, "pip")

# Go
bazel_dep(name = "rules_go", version = "0.57.0")

# Adds https://github.com/bazel-contrib/rules_go/commit/74199c92e20399b6ef46684b2c6fdd94b50a7892
# to fix bash issues with Nix
archive_override(
    module_name = "rules_go",
    integrity = "sha256-ukyyC80j4VhRCD7DOaenkk41Vvnmsp7uAfHr4lxdXtQ=",
    strip_prefix = "rules_go-74199c92e20399b6ef46684b2c6fdd94b50a7892",
    urls = ["https://github.com/bazel-contrib/rules_go/archive/74199c92e20399b6ef46684b2c6fdd94b50a7892.zip"],
)

# Rust
bazel_dep(name = "rules_rust", version = "0.61.0")

# C++ toolchain via zig-cc.
#
# - Hermetic:      YES
# - Speed:         SLOW  Optimized for size rather than speed of execution.
# - Download size: SMALL
#
# To test this toolchain, use for use with the config flag `--config=zig-cc`.
#
bazel_dep(name = "hermetic_cc_toolchain", version = "4.0.1")

zig = use_extension("@hermetic_cc_toolchain//toolchain:ext.bzl", "toolchains")
use_repo(
    zig,
    "zig_sdk",
)

# C++ toolchain via contrib/toolchains_llvm.
#
# - Hermetic: NO            LLVM artifacts are dynamically linked and will
#                           depend on your host's glibc.
# - Speed:         FAST     Release build optimized for speed of execution.
# - Download size: LARGE    Around 1.5 Gb for the linux toolchain.
#
# To test this toolchain, use for use with the config flag `--config=llvm`.
#
bazel_dep(name = "toolchains_llvm", version = "1.3.0")

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(llvm_version = "19.1.0")
use_repo(llvm, "llvm_toolchain")

# Example projects to test compilation.

# libcurl (C)
bazel_dep(name = "curl", version = "8.8.0.bcr.3")

# Zstandard (C)
bazel_dep(name = "zstd", version = "1.5.7")

# Abseil for C++
bazel_dep(name = "abseil-cpp", version = "20250127.0")

# Abseil for python
bazel_dep(name = "abseil-py", version = "2.1.0")

# Circl (Go, C++)
bazel_dep(name = "circl", version = "1.3.8")
